import { Vue, Component, Prop, Provide, Emit, Watch } from 'vue-property-decorator';
import { Subject } from 'rxjs';
import { CreateElement } from 'vue';
import './apply-apply-wzz-wfedit-view3.less';
import ApplyService from '@widgets/apply/apply-service';

import WFEditView3Engine from '@engine/view/wfedit-view3-engine';

import view_drtab from '@widgets/apply/apply-dr-drtab/apply-dr-drtab';
import view_form from '@widgets/apply/main-form/main-form';

@Component({
    components: {
        view_drtab, 
        view_form, 
    },
    beforeRouteEnter: (to: any, from: any, next: any) => {
        next((vm: any) => {
            vm.$store.commit('addCurPageViewtag', { fullPath: to.fullPath, viewtag: vm.viewtag });
        });
    },
})
export default class ApplyApply_WZZ_WFEditView3 extends Vue {

    /**
     * 实体服务对象
     *
     * @type {ApplyService}
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public entityService: ApplyService = new ApplyService();

    /**
     * 数据变化
     *
     * @param {*} val
     * @returns {*}
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    @Emit() 
    public viewDatasChange(val: any):any {
        return val;
    }

    /**
     * 数据视图
     *
     * @type {string}
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    @Prop() public viewdata!: string;

	/**
	 * 视图标识
	 *
	 * @type {string}
	 * @memberof ApplyApply_WZZ_WFEditView3
	 */
	public viewtag: string = '617797b9d213d3f22d88752ebd9b69a8';

    /**
     * 父数据对象
     *
     * @protected
     * @type {*}
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    protected srfparentdata: any = {};

    /**
     * 视图模型数据
     *
     * @type {*}
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public model: any = {
        srfTitle: '申请工作流视图(申请流程v1:组长审批)',
        srfCaption: 'apply.views.apply_wzz_wfeditview3.caption',
        srfSubCaption: '',
        dataInfo: ''
    }

    /**
     * 处理值变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    @Watch('viewdata')
    onViewData(newVal: any, oldVal: any) {
        const _this: any = this;
        if (!Object.is(newVal, oldVal) && _this.engine) {
            _this.engine.setViewData(newVal);
            _this.engine.load();
        }
    }

    /**
     * 容器模型
     *
     * @type {*}
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public containerModel: any = {
        view_drtab: { name: 'drtab', type: 'DRTAB' },
        view_toolbar: { name: 'toolbar', type: 'TOOLBAR' },
        view_form: { name: 'form', type: 'FORM' },
        wflinks: [],
    };

    /**
     * 视图状态订阅对象
     *
     * @private
     * @type {Subject<{action: string, data: any}>}
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public viewState: Subject<ViewState> = new Subject();

    /**
     * 工具栏模型
     *
     * @type {*}
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public toolBarModels: any = {
        tbitem24_c2: { name: 'tbitem24_c2', caption: '批准', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'C2', target: 'MULTIKEY' } },

        tbitem24_c22: { name: 'tbitem24_c22', caption: '驳回', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'C22', target: 'MULTIKEY' } },

        tbitem10: { name: 'tbitem10', caption: '当前流程步骤', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'ViewWFStep', target: 'SINGLEKEY' } },

        tbitem11: {  name: 'tbitem11', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } },
        tbitem23: { name: 'tbitem23', caption: '帮助', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'Help', target: '' } },

    };



    /**
     * 视图引擎
     *
     * @private
     * @type {Engine}
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    private engine: WFEditView3Engine = new WFEditView3Engine();

    /**
     * 引擎初始化
     *
     * @private
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    private engineInit(): void {
        this.engine.init({
            view: this,
            form: this.$refs.form,
            p2k: '0',
            drtab: this.$refs.drtab,
            isLoadDefault: true,
        });
    }

    /**
     * Vue声明周期
     *
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public created() {
        const secondtag = this.$util.createUUID();
        this.$store.commit('viewaction/createdView', { viewtag: this.viewtag, secondtag: secondtag });
        this.viewtag = secondtag;
        
    }

    /**
     * 销毁之前
     *
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public beforeDestroy() {
        this.$store.commit('viewaction/removeView', this.viewtag);
    }

    /**
     * Vue声明周期(组件初始化完毕)
     *
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public mounted() {
        const _this: any = this;
        _this.engineInit();
        if (_this.loadModel && _this.loadModel instanceof Function) {
            _this.loadModel();
        }
        
    }


    /**
     * drtab 部件 selectionchange 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public drtab_selectionchange($event: any, $event2?: any) {
        this.engine.onCtrlEvent('drtab', 'selectionchange', $event);
    }


    /**
     * toolbar 部件 click 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public toolbar_click($event: any, $event2?: any) {
        if (Object.is($event.tag, 'tbitem3')) {
            this.toolbar_tbitem3_click($event, '', $event2);
        }
        if (Object.is($event.tag, 'tbitem4')) {
            this.toolbar_tbitem4_click($event, '', $event2);
        }
        if (Object.is($event.tag, 'tbitem5')) {
            this.toolbar_tbitem5_click($event, '', $event2);
        }
        if (Object.is($event.tag, 'tbitem7')) {
            this.toolbar_tbitem7_click($event, '', $event2);
        }
        if (Object.is($event.tag, 'tbitem24_c2')) {
            this.toolbar_tbitem24_c2_click($event, '', $event2);
        }
        if (Object.is($event.tag, 'tbitem24_c22')) {
            this.toolbar_tbitem24_c22_click($event, '', $event2);
        }
        if (Object.is($event.tag, 'tbitem10')) {
            this.toolbar_tbitem10_click($event, '', $event2);
        }
        if (Object.is($event.tag, 'tbitem12')) {
            this.toolbar_tbitem12_click($event, '', $event2);
        }
        if (Object.is($event.tag, 'tbitem14')) {
            this.toolbar_tbitem14_click($event, '', $event2);
        }
        if (Object.is($event.tag, 'tbitem15')) {
            this.toolbar_tbitem15_click($event, '', $event2);
        }
        if (Object.is($event.tag, 'tbitem23')) {
            this.toolbar_tbitem23_click($event, '', $event2);
        }
    }


    /**
     * form 部件 save 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public form_save($event: any, $event2?: any) {
        this.engine.onCtrlEvent('form', 'save', $event);
    }


    /**
     * form 部件 remove 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public form_remove($event: any, $event2?: any) {
        this.engine.onCtrlEvent('form', 'remove', $event);
    }


    /**
     * form 部件 load 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public form_load($event: any, $event2?: any) {
        this.engine.onCtrlEvent('form', 'load', $event);
    }



    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem3_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.Save(datas, paramJO,  $event, xData);
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem4_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.SaveAndNew(datas, paramJO,  $event, xData);
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem5_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.SaveAndExit(datas, paramJO,  $event, xData);
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem7_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.RemoveAndExit(datas, paramJO,  $event, xData);
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem24_c2_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.Applyv1_C2(datas, paramJO,  $event, xData);
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem24_c22_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.Applyv1_C22(datas, paramJO,  $event, xData);
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem10_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.ViewWFStep(datas, paramJO,  $event, xData);
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem12_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.New(datas, paramJO,  $event, xData);
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem14_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.Copy(datas, paramJO,  $event, xData);
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem15_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.Print(datas, paramJO,  $event, xData);
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public toolbar_tbitem23_click(params: any = {}, tag?: any, $event?: any) {
        // 参数

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        const paramJO = {};
        xData = this.$refs.form;
        if (xData.getDatas && xData.getDatas instanceof Function) {
            datas = [...xData.getDatas()];
        }

        // 界面行为
        this.Help(datas, paramJO,  $event, xData);
    }


    /**
     * 保存
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public Save(args: any[], params?: any, $event?: any, xData?: any) {
        // 界面行为容器对象 _this
        const _this: any = this;
        if (xData && xData.save instanceof Function) {
            const _data = { srfparentdata: _this.srfparentdata };
            xData.save(_data).then((response: any) => {
                if (!response || response.status !== 200) {
                    return;
                }
                _this.$emit('viewdataschange', [{ ...response.data }]);
            });
        } else if (_this.save && _this.save instanceof Function) {
            _this.save();
        }
    }


    /**
     * 保存并新建
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public SaveAndNew(args: any[], params?: any, $event?: any, xData?: any) {
        const _view: any = this;
        if (!xData || !(xData.save instanceof Function)) {
            return;
        }
        const _data = { srfparentdata: _view.srfparentdata };
        xData.save(_data).then((response: any) => {
            if (!response || response.status !== 200) {
                return;
            }
            if (xData.autoLoad instanceof Function) {
                xData.autoLoad(_data);
            }
        });
    }

    /**
     * 保存并关闭
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public SaveAndExit(args: any[], params?: any, $event?: any, xData?: any) {
        // _this 指向容器对象
        // xData 数据对象
        const _this: any = this;
        if (xData && xData.save instanceof Function) {
            const _data = { srfparentdata: _this.srfparentdata };
            xData.save(_data).then((response: any) => {
                if (!response || response.status !== 200) {
                    return;
                }
                if (_this.viewdata) {
                    _this.$emit('viewdataschange', [{ ...response.data }]);
                    _this.$emit('close');
                } else if (_this.$tabPageExp) {
                    _this.$tabPageExp.onClose(_this.$route.fullPath);
                }
            });
        } else if (_this.save && _this.save instanceof Function) {
            _this.save().then((response: any) => {
                if (!response || response.status !== 200) {
                    return;
                }
                _this.$emit('closeview', [{ ...response.data }]);
            });
        }
    }

    /**
     * 删除并关闭
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public RemoveAndExit(args: any[], params?: any, $event?: any, xData?: any) {
        const _this: any = this;
        if (!xData || !(xData.remove instanceof Function)) {
            return ;
        }
        xData.remove(args).then((response: any) => {
            if (!response || response.status !== 200) {
                return ;
            }
            if (_this.viewdata) {
                _this.$emit('close');
            } else {
                _this.$tabPageExp.onClose(_this.$route.fullPath);
            }
        });
    }

    /**
     * 批准
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public Applyv1_C2(args: any[], params?: any, $event?: any, xData?: any) {
        const _this: any = this;
        if (!_this.entityService) {
            return;
        }
        const doProcessResult = () => {
            if (!xData || !(xData.getControlType instanceof Function)) {
                return;
            }

            if (Object.is(xData.getControlType(), 'GRID')) {
                xData.refresh();
            }
            if (Object.is(xData.getControlType(), 'FORM')) {
                _this.$store.dispatch('viewaction/datasaved', { viewtag: _this.viewtag });
                if (_this.viewdata) {
                    _this.$emit('viewdataschange', [...args]);
                    _this.$emit('close');
                } else if (_this.$tabPageExp) {
                    _this.$tabPageExp.onClose(_this.$route.fullPath);
                }
            }
        }

        let count: number = 0;
        for (let i = 0, len = args.length; i < len; i++) {
            const _promise: Promise<any> = _this.entityService.Applyv1_C2(args[i]);
            _promise.then(() => {
                count++;
                if (count === len) {
                    doProcessResult();
                }
            }).catch(() => {
                count++;
                if (count === len) {
                    doProcessResult();
                }
            })
        }
    }

    /**
     * 驳回
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public Applyv1_C22(args: any[], params?: any, $event?: any, xData?: any) {

        const data: any = { srfparentdata: {} };
        const _this: any = this;
        if (_this.srfparentdata) {
            Object.assign(data.srfparentdata, _this.srfparentdata);
        }
        
        if (args.length === 0) {
            return;
        }
        Object.assign(data, { srfkey: args[0].srfkey });

        const openPopupModal = (view: any, data: any) => {
            let container: Subject<any> = this.$appmodal.openModal(view, data);
            container.subscribe((result: any) => {
                if (!result || !Object.is(result.ret, 'OK')) {
                    return;
                }
                const _this: any = this;
                if (!_this.entityService) {
                    return;
                }

                const _promise: Promise<any> = _this.entityService.Applyv1_C22(result.datas[0]);
                if (!_promise) {
                    return;
                }
                _promise.then((_result: any) => {
                    if (!xData || !(xData.getControlType instanceof Function)) {
                        return;
                    }

                    if (Object.is(xData.getControlType(), 'GRID')) {
                        xData.refresh();
                    }
                    if (Object.is(xData.getControlType(), 'FORM')) {
                        _this.$store.dispatch('viewaction/datasaved', { viewtag: _this.viewtag });
                        if (_this.viewdata) {
                            _this.$emit('viewdataschange', [...result.datas]);
                            _this.$emit('close');
                        } else if (_this.$tabPageExp) {
                            _this.$tabPageExp.onClose(_this.$route.fullPath);
                        }
                    }
                });

            });
        }
        const view: any = {
            viewname: 'apply-reject-view', 
            height: 600, 
            width: 800,  
            title: '申请工作流操作视图', 
        };
        openPopupModal(view, data);
    }

    /**
     * 当前流程步骤
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public ViewWFStep(args: any[], params?: any, $event?: any, xData?: any) {

    }

    /**
     * 新建
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public New(args: any[], params?: any, $event?: any, xData?: any) {
         const _this: any = this;
        if (_this.newdata && _this.newdata instanceof Function) {
            const data: any = {};
            if (_this.srfparentdata) {
                Object.assign(data, _this.srfparentdata);
            }
            _this.newdata([{ ...data }], params, $event, xData);
        } else {
            _this.$Notice.error({ title: '错误', desc: 'newdata 视图处理逻辑不存在，请添加!' });
        }
    }

    /**
     * 拷贝
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public Copy(args: any[], params?: any, $event?: any, xData?: any) {
        if (args.length === 0) {
            return;
        }
        const _this: any = this;
        if (_this.newdata && _this.newdata instanceof Function) {
            const data: any = {};
            if (args.length > 0) {
                Object.assign(data, { srfsourcekey: args[0].srfkey })
            }
            if (_this.srfparentdata) {
                Object.assign(data, _this.srfparentdata);
            }
            _this.newdata([{ ...data }], params, $event, xData);
        } else if (xData && xData.copy instanceof Function) {
            const data2: any = {};
            if (args.length > 0) {
                Object.assign(data2, { srfsourcekey: args[0].srfkey })
            }
            if (_this.srfparentdata) {
                Object.assign(data2, _this.srfparentdata);
            }
            xData.copy(data2);
        } else {
            _this.$Notice.error({ title: '错误', desc: 'opendata 视图处理逻辑不存在，请添加!' });
        }
    }

    /**
     * 打印
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public Print(args: any[], params?: any, $event?: any, xData?: any) {

    }

    /**
     * 帮助
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public Help(args: any[], params?: any, $event?: any, xData?: any) {

    }

    /**
     * 关闭视图
     *
     * @param {any[]} args
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public closeView(args: any[]): void {
        let _view: any = this;
        if (_view.viewdata) {
            _view.$emit('viewdataschange', args);
            _view.$emit('close');
        } else if (_view.$tabPageExp) {
            _view.$tabPageExp.onClose(_view.$route.fullPath);
        }
    }

    /**
     * 选中数据
     *
     * @type {*}
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public selection: any = {};
    

    /**
     * 绘制视图消息 （上方）
     *
     * @returns
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public renderPosTopMsgs() {
        return (
            <div class='view-top-messages'>
            </div>
        );
    }

    /**
     * 绘制视图消息 （下方）
     *
     * @returns
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public renderPosBottomMsgs() {
        return (
            <div class='view-bottom-messages'>
            </div>
        );
    }
    
    /**
     * 绘制内容
     *
     * @param {CreateElement} h
     * @returns
     * @memberof ApplyApply_WZZ_WFEditView3
     */
    public render(h: CreateElement) {
        return (
        <div class="view-container apply-apply-wzz-wfedit-view3">
            <card class='view-card' dis-hover={true} bordered={false}>
        
        <p slot='title'>
            <span class='caption-info'>
                {this.$t(this.model.srfCaption)}
                {
                    this.model.dataInfo && !Object.is(this.model.dataInfo, '') ?
                        ': ' + this.model.dataInfo
                        : ''
                }
            </span>
        </p>
            
                <p slot="extra" v-show={Object.is(this.selection.id, 'form')}>
                <div class='toolbar-container'>
                        <tooltip transfer={true} max-width={600}>
                    <i-button v-show={this.toolBarModels.tbitem24_c2.visabled} disabled={this.toolBarModels.tbitem24_c2.disabled} class='' on-click={($event: any) => this.toolbar_click({ tag: 'tbitem24_c2' }, $event)}>
                        <i class=''></i>
                        <span class='caption'>{this.$t('apply.apply_wzz_wfeditview3toolbar_toolbar.tbitem24_c2.caption')}</span>
                    </i-button>
                    <div slot='content'>{this.$t('apply.apply_wzz_wfeditview3toolbar_toolbar.tbitem24_c2.tip')}</div>
                </tooltip>
                
                
                    <tooltip transfer={true} max-width={600}>
                    <i-button v-show={this.toolBarModels.tbitem24_c22.visabled} disabled={this.toolBarModels.tbitem24_c22.disabled} class='' on-click={($event: any) => this.toolbar_click({ tag: 'tbitem24_c22' }, $event)}>
                        <i class=''></i>
                        <span class='caption'>{this.$t('apply.apply_wzz_wfeditview3toolbar_toolbar.tbitem24_c22.caption')}</span>
                    </i-button>
                    <div slot='content'>{this.$t('apply.apply_wzz_wfeditview3toolbar_toolbar.tbitem24_c22.tip')}</div>
                </tooltip>
                
                
                    <tooltip transfer={true} max-width={600}>
                    <i-button v-show={this.toolBarModels.tbitem10.visabled} disabled={this.toolBarModels.tbitem10.disabled} class='' on-click={($event: any) => this.toolbar_click({ tag: 'tbitem10' }, $event)}>
                        <i class='sx-tb-stepactor'></i>
                        <span class='caption'>{this.$t('apply.apply_wzz_wfeditview3toolbar_toolbar.tbitem10.caption')}</span>
                    </i-button>
                    <div slot='content'>{this.$t('apply.apply_wzz_wfeditview3toolbar_toolbar.tbitem10.tip')}</div>
                </tooltip>
                
                
                    <span class='seperator'>|</span>
                    <tooltip transfer={true} max-width={600}>
                    <i-button v-show={this.toolBarModels.tbitem23.visabled} disabled={this.toolBarModels.tbitem23.disabled} class='' on-click={($event: any) => this.toolbar_click({ tag: 'tbitem23' }, $event)}>
                        <i class='fa fa-question'></i>
                        <span class='caption'>{this.$t('apply.apply_wzz_wfeditview3toolbar_toolbar.tbitem23.caption')}</span>
                    </i-button>
                    <div slot='content'>{this.$t('apply.apply_wzz_wfeditview3toolbar_toolbar.tbitem23.tip')}</div>
                </tooltip>
                
                
                </div>
                
                </p>
                <div class="content-container">
                    <view_drtab 
                    viewState={this.viewState} 
                    name='drtab' 
                    ref='drtab' 
                    on-selectionchange={($event: any) => this.drtab_selectionchange($event)} 
                    on-closeview={($event: any) => this.closeView($event)}>
                    <view_form 
                    viewState={this.viewState} 
                        autosave={false} 
                    viewtag={this.viewtag} 
                    showBusyIndicator={true} 
                    updateAction='update' 
                    removeAction='remove' 
                    loaddraftAction='getdraft' 
                    loadAction='get' 
                    createAction='create' 
                    style='' 
                 
                    name='form' 
                    ref='form' 
                    on-save={($event: any) => this.form_save($event)} 
                    on-remove={($event: any) => this.form_remove($event)} 
                    on-load={($event: any) => this.form_load($event)} 
                    on-closeview={($event: any) => this.closeView($event)}>
                </view_form>
                </view_drtab>
        
                </div>
            </card>
        </div>
        );
    }


}